package com.alnex.activiti.ZKdemo;

// 功能描述:(第五步生成订单号的线程)

public class OrderServicesynchronized implements Runnable{
	//1.生成订单号
	OrderNumGenerator orderNumGenerator = new OrderNumGenerator();
	
	private IZKLock zkLock = new ZookeeperDistrbuteLock();
	
	public void run() {
		try {
			//获取锁资源
			zkLock.getLock();
			getNumber();
			
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			//释放锁资源
			zkLock.unLock();
		}
	
	}
	// 获取流水号
	public void getNumber() {
		String number = orderNumGenerator.getNumber();
		System.out.println(Thread.currentThread().getId() + ",####number:" + number);
	}
	
}

